#include <lorcon2/lorcon_endian.h>
#include <stdio.h>

int16_t cksum(uint8_t * header, int len) {

        uint32_t value =0;
        uint16_t *temp;
        uint16_t main, high;
        int word_len = len/2;
        int i =0;
        temp = (uint16_t *) header;
        for (i=0; i<word_len; i++) {
                if ( i == 5)
                        continue;
                value += lorcon_swap16(temp[i]);
        }
        main = value;
        high = (value & 0xFF0000 )>>16;
        return (~(main+high)) & 0xFFFF;
}
